<div class="clearfix">
  <div class="btn-group pull-left">
    <a href="/tickets" class="btn btn-default">我的工单</a>
    <a href="/history" class="btn btn-default active">广场</a>
  </div>
  <a class="btn btn-primary" href="/tickets/new" style="margin-left: 10px;">新建工单</a>
  <% include browser_notification %>
</div>

<hr>

<div>
    <div>
        <ul class="nav nav-tabs">
            <li id="all_link">
              <a href="/history">所有</a>
            </li>
            <li id="ios_link">
                <a href="/history?type=ios">iOS SDK</a>
            </li>
            <li id="android_link">
                <a href="/history?type=android">Android SDK</a>
            </li>
            <li id="javascript_link">
                <a href="/history?type=javascript">JavaScript SDK SDK</a>
            </li>
            <li id="push_link">
                <a href="/history?type=push">消息推送</a>
            </li>
            <li id="cloud_link">
                <a href="/history?type=cloud">云代码</a>
            </li>
            <li id="stats_link">
                <a href="/history?type=stats">统计</a>
            </li>
            <li id="dashboard_link">
                <a href="/history?type=dashboard">开发者平台</a>
            </li>
            <li id="other_link">
                <a href="/history?type=other">其他</a>
            </li>
        </ul>

        <table class="table table-borderless table-sortable">
            <thead>
              <tr>
                <th data-sort="int">#</th>
                <th data-sort="string">标题</th>
                <th data-sort="string">类型</th>
                <th data-sort="int" data-sort-default="desc" data-sort-onload>创建时间</th>
              </tr>
            </thead>
            <tbody>
            <% tickets.forEach (function (ticket){  %>
            <tr>
              <td class="table-id" data-sort-value="<%=ticket.ticket_id%>">#<%= ticket.ticket_id%></td>
              <td class="table-title"><a href="/tickets/<%=ticket.id%>/threads" title="#<%= ticket.ticket_id %>"><%= ticket.title %></a></td>
              <td class="table-type"><%= ticket.type %></td>
              <td class="table-date" data-sort-value="<%= ticket.createdAtUnix %>"><span class="bstooltip" title="<%= ticket.createdAtLong %>"><%= ticket.createdAt %></span></td>
            </tr>
            <%} ) %>
            </tbody>
        </table>
    </div>
  <div class="search-page">
    <ul class="pagination">
      <% if(back >= 0) { %>
      <% if(type != null) { %>
      <li><a href="/history?type=<%= type %>&skip=<%= back %>">上一页</a></li>
      <% }else{ %>
      <li><a href="/history?skip=<%= back %>">上一页</a></li>
      <% } %>
      <% } %>
      <% if(next > 0) { %>
      <% if(type != null) { %>
      <li><a href="/history?type=<%= type %>&skip=<%= next %>">下一页</a></li>
      <% }else{ %>
      <li><a href="/history?skip=<%= next %>">下一页</a></li>
      <% } %>
      <% } %>
    </ul>
  </div>
</div>

<script type="text/javascript">
    var url = document.URL;
    if (/.*type=ios.*/.exec(url)){
        $('#ios_link').attr('class','active');
    }else if (/.*type=android.*/.exec(url)){
        $('#android_link').attr('class','active');
    }else if (/.*type=javascript.*/.exec(url)){
        $('#javascript_link').attr('class','active');
    }else if (/.*type=push.*/.exec(url)){
        $('#push_link').attr('class','active');
    }else if (/.*type=cloud.*/.exec(url)){
        $('#cloud_link').attr('class','active');
    }else if (/.*type=stats.*/.exec(url)){
        $('#stats_link').attr('class','active');
    }else if (/.*type=cloud.*/.exec(url)){
        $('#cloud_link').attr('class','active');
    }else if (/.*type=dashboard.*/.exec(url)){
        $('#dashboard_link').attr('class','active');
    }else if (/.*type=other.*/.exec(url)){
        $('#other_link').attr('class','active');
    }else{
      $('#all_link').attr('class','active');
    }
</script>

